package com.qianfeng.myymatou.activity;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.qianfeng.myymatou.R;

/**
 * “搜索”界面，在“首页”、“直播”、“特卖”界面点击搜索跳转到的界面
 */
public class SearchActivity extends AppCompatActivity {
    //TODO 这里要做一个流式布局，作为搜索标签

    private Context mContext = this;

    private Toolbar mTbSearch;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_search);

        //找控件
        findView();

        //初始化Toolbar
        initSearchToolbar();
    }

    /**
     * 初始化Toolbar
     */
    private void initSearchToolbar() {
        mTbSearch.setNavigationIcon(R.mipmap.ic_go_back);
        mTbSearch.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        View viewInSearchTb = LayoutInflater.from(mContext).inflate(R.layout.layout_tb_search, null);
        mTbSearch.addView(viewInSearchTb);
        TextView tvSearch = (TextView) viewInSearchTb.findViewById(R.id.tv_search);
        tvSearch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //TODO 搜索后跳转
                Toast.makeText(mContext, "点击了搜索", Toast.LENGTH_SHORT).show();
            }
        });
    }

    /**
     * 找控件
     */
    private void findView() {
        mTbSearch = (Toolbar) findViewById(R.id.tb_search);
    }
}
